<template>
  <div class="photoinfo-container">
    <h3 class="photoinfo-title">{{photoinfolist.title}}</h3>
    <p class="photoinfo-info">
      <span>发表时间:{{photoinfolist.add_time|dateFormat}}</span>
      <span>点击次数:{{photoinfolist.click}}次</span>
    </p>
    <hr />
    <vue-preview :slides="slide1" @close="handleClose"></vue-preview>
    <div class="photoinfo-content" v-html="photoinfolist.content"></div>
    <comment-box :id="this.id"></comment-box>
  </div>
</template>
<script>
import comment from "../subcomponents/comment.vue";
export default {
  data() {
    return {
      id: this.$route.params.id,
      photoinfolist: {},
      slide1: []
    };
  },
  created() {
    this.getPhotoInfo();
    this.getThumbs();
  },
  methods: {
    getPhotoInfo() {
      this.axios.get("api/getimageInfo/" + this.id).then(response => {
        if (response.data.status === 0) {
          this.photoinfolist = response.data.message[0];
        }
      });
    },
    getThumbs() {
      this.axios.get("api/getthumimages/" + this.id).then(response => {
        if (response.data.status === 0) {
          response.data.message.forEach(item => {
            item.msrc = item.src;
            item.w = 600;
            item.h = 400;
          });
          this.slide1 = response.data.message;
        }
      });
    },
    handleClose() {
      // console.log("close event");
    }
  },
  components: {
    "comment-box": comment
  }
};
</script>
<style lang="scss">
.photoinfo-container {
  padding: 3px;
  .photoinfo-title {
    text-align: center;
    font-size: 15px;
    color: #26a2ff;
    margin: 15px 0;
  }
  .photoinfo-info {
    font-size: 13px;
    display: flex;
    justify-content: space-between;
  }
  .my-gallery {
    figure {
      display: inline-block;
      margin: 8px;
    }
    img {
      width: 80px;
      height: 60px;
    }
  }
  .photoinfo-content {
    font-size: 13px;
    line-height: 35px;
  }
}
</style>